package com.ruoyi.api.mail;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.JiajiaMallProductEvaluation;
import com.ruoyi.system.service.IJiajiaMallProductEvaluationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商城商品评价信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-05
 */
@Controller
@RequestMapping("/api/mall/evaluation")
public class ApiJiajiaMallProductEvaluationController
{
    private String prefix = "mall/evaluation";

    @Autowired
    private IJiajiaMallProductEvaluationService jiajiaMallProductEvaluationService;

    //@RequiresPermissions("system:evaluation:view")
    @GetMapping()
    public String evaluation()
    {
        return prefix + "/evaluation";
    }

    /**
     * 查询商城商品评价信息列表
     */
    //@RequiresPermissions("system:evaluation:list")
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult list(JiajiaMallProductEvaluation jiajiaMallProductEvaluation)
    {
        List<JiajiaMallProductEvaluation> list = jiajiaMallProductEvaluationService.selectJiajiaMallProductEvaluationList(jiajiaMallProductEvaluation);
        return AjaxResult.success(list);
    }

    /**
     * 导出商城商品评价信息列表
     */
    //@RequiresPermissions("system:evaluation:export")
    @Log(title = "商城商品评价信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaMallProductEvaluation jiajiaMallProductEvaluation)
    {
        List<JiajiaMallProductEvaluation> list = jiajiaMallProductEvaluationService.selectJiajiaMallProductEvaluationList(jiajiaMallProductEvaluation);
        ExcelUtil<JiajiaMallProductEvaluation> util = new ExcelUtil<JiajiaMallProductEvaluation>(JiajiaMallProductEvaluation.class);
        return util.exportExcel(list, "商城商品评价信息数据");
    }

    /**
     * 新增商城商品评价信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商城商品评价信息
     */
    //@RequiresPermissions("system:evaluation:add")
    @Log(title = "商城商品评价信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaMallProductEvaluation jiajiaMallProductEvaluation)
    {
        return AjaxResult.success(jiajiaMallProductEvaluationService.insertJiajiaMallProductEvaluation(jiajiaMallProductEvaluation));
    }

    /**
     * 修改商城商品评价信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaMallProductEvaluation jiajiaMallProductEvaluation = jiajiaMallProductEvaluationService.selectJiajiaMallProductEvaluationById(id);
        mmap.put("jiajiaMallProductEvaluation", jiajiaMallProductEvaluation);
        return prefix + "/edit";
    }

    /**
     * 修改保存商城商品评价信息
     */
    //@RequiresPermissions("system:evaluation:edit")
    @Log(title = "商城商品评价信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaMallProductEvaluation jiajiaMallProductEvaluation)
    {
        return AjaxResult.success(jiajiaMallProductEvaluationService.updateJiajiaMallProductEvaluation(jiajiaMallProductEvaluation));
    }

    /**
     * 删除商城商品评价信息
     */
    //@RequiresPermissions("system:evaluation:remove")
    @Log(title = "商城商品评价信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return AjaxResult.success(jiajiaMallProductEvaluationService.deleteJiajiaMallProductEvaluationByIds(ids));
    }
}
